package com.example.constants;

import java.util.HashMap;
import java.util.Map;
import com.example.vo.DataBaseVo;
import groovy.util.XmlParser;

@Singleton(lazy = true,strict  = false)
class DataBaseConfig {

	def static Map<String, DataBaseVo> dbmap = new HashMap<>();
	private  DataBaseConfig() {
		
		println("执行初始化方法...")
		
		def parser = new XmlParser()
		def doc =  parser.parse("d://groovyTest/dbConfig.xml");
		def iter = doc.iterator();
		while(iter.hasNext()) {
			def e = iter.next();
			DataBaseVo d = new DataBaseVo();
			d.setUrl(e.url.text());
			d.setUser(e.user.text());
			d.setPassword(e.password.text());
			dbmap.put(e.dbname.text(), d);
		}
		
	}

}
